/*
 *  include/asm/i8253.h
 *
 *  last modified 2007-07-14 21:55 by ChenJie
 *
 */

#ifndef I8253_H
#define I8253_H

/*
 * 功能:
 * 	i8253定时器的初始化
 * 输入:
 * 	nr	使用的定时器编号:0,1,2
 * 	mode	使用的模式:0,1,2,3,4,5
 * 	counter	计数值0~0xffff
 * 输出:
 * 	无
 * 全局变量:
 * 	无
 * 处理说明:
 * 	CLK0.OUT ---> 8259.IRQ0
 * 	CLK1.OUT ---> 8237.DREQ0
 * 	CLK2.OUT ---> 8255.PC5
 *
 * 	CLK = 1.19MHz
 *
 * 	Mode 0:	Interrupt on terminal count
 * 	Mode 1:	Programmable one shot
 * 	Mode 2: Rate Generator
 * 	Mode 3: Square wave rate Generator
 * 	Mode 4: Software triggered strobe
 * 	Mode 5: Hardware trigered strobe
 */
static inline void i8253_init(int nr, int mode, unsigned short counter)
{
	__asm__("\tmovb $0x36, %%al\n"
		"\toutb %%al, $0x43\n"
		"\toutb %%al, $0x40\n"
		"\tmovb	%%ah, %%al\n"
		"\toutb %%al, $0x40\n"
		::"a"(counter)
	       );
}

#endif // I8253_H
